#define _CRT_SECURE_NO_WARNINGS 1
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode() : val(0), next(nullptr) {}
 *     ListNode(int x) : val(x), next(nullptr) {}
 *     ListNode(int x, ListNode *next) : val(x), next(next) {}
 * };
 */
class Solution {
public:
    ListNode* swapPairs(ListNode* head)
    {
        ListNode* new_head = new ListNode;
        ListNode* cur = head;
        ListNode* new_cur = new_head;
        while (cur && cur->next)
        {
            ListNode* tmp1 = new ListNode(cur->next->val);
            new_cur->next = tmp1;
            new_cur = new_cur->next;
            ListNode* tmp2 = new ListNode(cur->val);
            new_cur->next = tmp2;
            new_cur = new_cur->next;
            cur = cur->next->next;
        }
        if (cur) new_cur->next = cur;
        return new_head->next;
    }
};